<template>
  <view style="padding: 10px 20px">
    <u-swiper
      :list="IndexData.lunbotu.list"
      keyName="img_url"
      indicatorMode="line"
      circular
      indicator
      @click="handleSwiperChange"
    ></u-swiper>
    <uGrid
      :baseList="
        IndexData.jingangqu.list.map((item) => {
          return {
            ...item,
            url: `/${item.page_url}`,
          };
        })
      "
    />
    <!-- <newsPage :baseList="IndexData.yanjiuyuan.list"/> -->
    <view style="margin-top: 10px">
      <uTabs :baseList="tabBasicList" @change="tabChange" />
      <mainList
        :baseList="
          tabIndex === 0 ? IndexData.wubaiqiang.list : IndexData.yinxing.list
        "
        url="/pages/hignList/details"
      />
    </view>
    <view>
      <pageTitle title="高端大会" url="/pages/hignEnd/index"></pageTitle>
      <mainList
        :baseList="IndexData.dahui.list"
        url="/pages/hignEnd/details"
        type="high"
      />
    </view>
    <view>
      <pageTitle title="独角兽资讯" url="/pages/news/index"></pageTitle>
      <mainList
        :baseList="
          IndexData.zixun.list.map((item) => {
            return {
              ...item,
              name: item.title,
              desc_text: item.synopsis,
              tag: item.add_time,
              img_url: item.image_input,
            };
          })
        "
        url="/pages/news/details"
        type="unicorn"
        category="product_tzjg"
      />
    </view>
  </view>
</template>
<script>
import newsPage from "./news-page.vue";
import uTabs from "@/components/uTabs/index.vue";
import mainList from "@/components/mainList/index.vue";
import pageTitle from "@/components/pageTitle.vue";
import uGrid from "@/components/uGrid/index.vue";

export default {
  components: {
    newsPage,
    mainList,
    uGrid,
    uTabs,
    pageTitle,
  },
  data() {
    return {
      indicatorDots: true,
      autoplay: true,
      interval: 2000,
      duration: 500,
      IndexData: {
        lunbotu: {
          list: [],
        },
        yanjiuyuan: {
          list: [],
        },
        wubaiqiang: {
          list: [],
        },
        yinxing: {
          list: [],
        },
        dahui: {
          list: [],
        },
        zixun: {
          list: [],
        },
        jingangqu: {
          list: [],
        },
      },
      tabIndex: 0,
      baseList: [
        //     {
        //     name: 'order',
        //     desc_text: '创业伯乐研究',
        //     url:'/pages/research/index',
        //     tabbar:true
        // },
        {
          name: "lock",
          desc_text: "企业库",
          url: "/pages/company/index",
        },
        {
          name: "star",
          desc_text: "独角兽榜单",
          url: "/pages/hignList/index",
          tabbar: true,
        },
        {
          name: "star",
          desc_text: "推荐项目",
          url: "/pages/project/index",
          tabbar: true,
        },
        {
          name: "star",
          desc_text: "独角兽资讯",
          url: "/pages/news/index",
        },
        {
          name: "star",
          desc_text: "投资机构",
          url: "/pages/invest/index",
        },
        {
          name: "star",
          desc_text: "高端大会",
          url: "/pages/hignEnd/index",
        },
        {
          name: "star",
          desc_text: "新商学EDP",
          url: "/pages/company/traning",
        },
        {
          name: "star",
          desc_text: "加速器",
          url: "/pages/incubator/index",
        },
      ],
      tabBasicList: [
        {
          name: "全球独角兽企业500强",
        },
        {
          name: "中国隐形独角兽500强",
        },
      ],
      top: {
        0: [],
        1: [],
      },
    };
  },
  onShow() {
    this.getIndexData();
    // git提交测试
  },
  methods: {
    changeIndicatorDots(e) {
      this.indicatorDots = !this.indicatorDots;
    },
    changeAutoplay(e) {
      this.autoplay = !this.autoplay;
    },
    intervalChange(e) {
      this.interval = e.target.value;
    },
    durationChange(e) {
      this.duration = e.target.value;
    },
    async getIndexData() {
      const res = await this.$api.getIndex({});
      this.IndexData = res;
    },
    tabChange(e) {
      this.tabIndex = e;
    },
    handleSwiperChange(index) {
     
      uni.navigateTo({
        url: index === 0 ? "/pages/reading/traning" : "/pages/incubator/index",
      });
    },
  },
};
</script>

.wrap {
padding: 12px;
}

.demo-layout {
height: 25px;
border-radius: 4px;
}

.bg-purple {
background: #CED7E1;
}

.bg-purple-light {
background: #e5e9f2;
}

.bg-purple-dark {
background: #99a9bf;
}